<?php
/**
 * @author sixihaoyue <sixihaoyue@qq.com>
 */
class FileModel extends BpfModel
{
  private function __init()
  {
    $this->_localDir = $this->getIni('upload_path', 'files');
     makedir(DOCPATH . $this->_localDir);
  }

  public function upload($type, $source, $filename, $contentType = null)
  {
    $url = $this->_localDir . '/' . $type . '/' . $filename;
    $dest = DOCPATH . $url;
    makedir(dirname($dest));
    if (!copy($source, $dest)) {
      return false;
    }
    return url($url, true);
  }
}
